import java.nio.file.Path;
import java.util.Arrays;

public class Dfs{
    static int N=5;
    static int n=3;
    static int path[]=new int[N];
    static boolean st[]=new boolean[N];
    public static void main(String[] args) {
        dfs(0);
    }
    static void dfs(int u){
        if(u==n){
            for(int i=0;i<n;i++){
                System.out.print(path[i]+" ");
                
            }
            System.out.println(" ");
            return;
        }
        for(int i=1;i<=n;i++){
            if(!st[i]){
                path[u]=i;
                st[i]=true;
                dfs(u+1);
                st[i]=false;
            }
        }
    }
}